package ctn.util;

import java.util.HashMap;
import java.util.Map;

import ctn.contant.WebConstant;
import ctn.hibernate.po.CtnUser;

public class CTNUserUtil {
	private static final ThreadLocal tl = new ThreadLocal();

	public static CtnUser getUser() {
		Map map = (Map) tl.get();
		if(map==null){
			return null;
		}
		CtnUser user = (CtnUser) map.get(WebConstant.USER);
		LogUtil.printInfo("Login user is "+user.getName());
		return user;

	}

	public static void set(CtnUser user) {
		Map map = (Map) tl.get();

		if (map == null) {
			map = new HashMap();
			tl.set(map);
		}
		map.put(WebConstant.USER, user);
	}
}
